package com.example.designpattern.criteria;

import java.util.List;

/**
 * @author: cph
 * @date: 2022/2/14 17:59
 */
public class AndCriteria implements Criteria {

    private Criteria criteria;
    private Criteria otherCriteria;

    public AndCriteria(Criteria criteria, Criteria otherCriteria) {
        this.criteria = criteria;
        this.otherCriteria = otherCriteria;
    }

    @Override
    public List<Person> meetCriteria(List<Person> personList) {
        List<Person> firstCriteriaList = criteria.meetCriteria(personList);
        return otherCriteria.meetCriteria(firstCriteriaList);
    }
}
